from skimage import data, filters
from matplotlib import pyplot as plt 
# img为原始图像
img = data.camera()
# sobel算子
img_sobel_h = filters.sobel_h(img)
img_sobel_v = filters.sobel_v(img)
img_sobel = filters.sobel(img)
# 显示图像
plt.rcParams['font.sans-serif'] = ['SimHei'] 
plt.rcParams['axes.unicode_minus'] = False
plt.subplot(2, 2, 1)
plt.axis('off')
plt.imshow(img, cmap = 'gray')
plt.title('原图像')
plt.subplot(2, 2, 2)
plt.axis('off')
plt.imshow(img_sobel_h, cmap = 'gray')
plt.title('sobel_h')
plt.subplot(2, 2, 3)
plt.axis('off')
plt.imshow(img_sobel_v, cmap = 'gray')
plt.title('sobel_v')
plt.subplot(2, 2, 4)
plt.axis('off')
plt.imshow(img_sobel, cmap = 'gray')
plt.title('sobel')
plt.savefig('sobels.tif')
